package ui.panels.commands;

import javax.swing.JPanel;

import ui.flowManager.FlowManagerImpl;
import ui.panels.ThirdPanel;
import ui.panels.primary.playerProperties.PlayerPropertiesPanel_2;
import gameEngine.agents.choosingStrategy.representation.StrategyRepresentation;

/**
 * @author vladimir && alon
 *	The class is set StrategyRepresentation in Player Properties Panel
 *	The creation of this command is designed for use strategies GUI, to set the strategy 
 */
public class SetStrategyRepresentationCommand implements Command{

	private StrategyRepresentation strategyRepresentation = null;
	
	public void execute()
	{
		if(strategyRepresentation != null)
		{
			//get the last created panel  
			JPanel panel = FlowManagerImpl.getInstance().getLastPanel();
			//check that this is third panel - the panel that split to 3 parts
			if(panel instanceof ThirdPanel)
			{
				//cast
				ThirdPanel thirdPanel = (ThirdPanel) panel;
				//get the player properties panel
				panel = thirdPanel.getLastPanelCreated();
				//check that it is real the properties panel
				if(panel instanceof PlayerPropertiesPanel_2)
				{
					//cast and set the distribution
					PlayerPropertiesPanel_2 propertiesPanel = (PlayerPropertiesPanel_2) panel;
					propertiesPanel.setStrategyRepresentation(strategyRepresentation);
				}
			}
		}
		//end first if

	}

	
	public void setStrategyRepresentation(
			StrategyRepresentation strategyRepresentation) {
		this.strategyRepresentation = strategyRepresentation;
	}
	
		
}
